package demoMod.invincibleOne.cards.invincible;

import basemod.helpers.CardModifierManager;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.StrengthPower;
import demoMod.invincibleOne.InvincibleOneMod;
import demoMod.invincibleOne.enums.CardTagsEnum;
import demoMod.invincibleOne.interfaces.SpawnMonsterHook;
import demoMod.invincibleOne.modifiers.ExhaustAtStartOfCombatMod;

@Deprecated
public class PayDay extends AbstractInvincibleCard implements SpawnMonsterHook {
    public static final String ID = InvincibleOneMod.makeID("PayDay");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/todo";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = CardRarity.UNCOMMON;
    private static final CardTarget TARGET = CardTarget.SELF;

    private static final int COST = -2;

    public PayDay() {
        super(ID, NAME, InvincibleOneMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.modifier = new ExhaustAtStartOfCombatMod();
        this.tags.add(CardTagsEnum.ALERT);
        this.modifier = new ExhaustAtStartOfCombatMod();
        CardModifierManager.addModifier(this, modifier);
        this.baseMagicNumber = this.magicNumber = 3;
        this.misc = 3;
        this.rawDescription = String.format(cardStrings.DESCRIPTION, this.misc);
        this.initializeDescription();
    }

    @Override
    public boolean onBattleStart() {
        if (this.misc > 0) {
            for (AbstractMonster m : AbstractDungeon.getMonsters().monsters) {
                addToBot(new ApplyPowerAction(m, m, new StrengthPower(m, this.magicNumber)));
            }
        }
        this.misc--;
        this.rawDescription = String.format(cardStrings.DESCRIPTION, Math.max(this.misc, 0));
        this.initializeDescription();
        return this.misc >= 0;
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            upgradeMagicNumber(1);
            this.rawDescription = String.format(cardStrings.DESCRIPTION, Math.max(this.misc, 0));
            this.initializeDescription();
        };
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {

    }

    @Override
    public void onSpawnMonster(AbstractMonster m) {
        if (this.misc >= 0) {
            addToBot(new ApplyPowerAction(m, m, new StrengthPower(m, this.magicNumber)));
        }
    }
}
